package edu.wuwang.audiovideo;



import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class MainActivity extends AppCompatActivity implements SurfaceHolder.Callback {

    private CameraDecode cameraDecode;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SurfaceView surfaceView = new SurfaceView(this);
        SurfaceHolder holder = surfaceView.getHolder();
        holder.addCallback(this);
        setContentView(surfaceView);


    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {

    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        if (cameraDecode==null){
            cameraDecode = new CameraDecode();
            cameraDecode.prepare(holder.getSurface());
        }


    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        if (cameraDecode!=null){
            cameraDecode = new CameraDecode();
            cameraDecode.prepare(holder.getSurface());
        }
    }
}
